package com.jml.代理模式.动态代理.jdk;

import java.lang.reflect.Proxy;

public class Main {

    public static void main(String[] args) throws Exception {
        // 被代理对象
        IUserDao userDao = new IUserDaoImpl();
        InvocationHandlerImpl invocationHandlerImpl = new InvocationHandlerImpl(userDao);
        //类加载器
        ClassLoader loader = userDao.getClass().getClassLoader();
        Class<?>[] interfaces = userDao.getClass().getInterfaces();
        // 主要装载器、一组接口及调用处理动态代理实例
        IUserDao newProxyInstance = (IUserDao) Proxy.newProxyInstance(loader, interfaces, invocationHandlerImpl);
        newProxyInstance.save();
        newProxyInstance.insert();
    }
}
